package org.home.and.controller;


import org.home.and.feign.ISystemClient;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liou
 */
@RestController
@RefreshScope
public class TestController {

    public TestController(@Qualifier("org.home.and.feign.ISystemClient") ISystemClient sysClient) {
        this.sysClient = sysClient;
    }

    private final ISystemClient sysClient;

    @Value("${user.name}")
    private String userName;

    @GetMapping(value ="/echo/{str}")
    public String echo(@PathVariable String str) {
        return "hello Nacos discovery" + str;
    }

    @GetMapping(value ="/getById")
    public String getById(@RequestParam("str") String str) throws Exception {
        return sysClient.getById(str) + "--本人：" + userName;
    }
}
